package com.beijiteshop.shop.ui.home.adapter

import android.graphics.drawable.Drawable
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.youth.banner.adapter.BannerAdapter

class ImageBannerAdapter(val drawables: List<Drawable>) : BannerAdapter<Drawable,ViewHolder>(drawables) {
    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
        val imageView: ImageView = ImageView(parent?.context)
        val layoutParams: ViewGroup.LayoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT)
        imageView.layoutParams = layoutParams
        imageView.scaleType = ImageView.ScaleType.CENTER_CROP
        return ViewHolder(imageView)
    }

    override fun onBindView(holder: ViewHolder?, data: Drawable?, position: Int, size: Int) {
        holder?.imageView?.setImageDrawable(data)
    }

}

class ViewHolder(val imageView: ImageView): RecyclerView.ViewHolder(imageView)